let arr = [1, 2, 3]

function subsets(nums) {
    const res = []
    const len = nums.length
    const subset = []

    function dfs(index) {
        res.push([...subset])
        for (let i = index; i < len; i++) {
            subset.push(nums[i])  // 放进盒子中
            dfs(i + 1)
            subset.pop()
        }
    }

    dfs(0)

    return res
}